var fs = require('fs');

var data = '';

var rstream = fs.createReadStream('a.txt');

rstream.setEncoding('utf8');

// stream data event
rstream.on('data', function(chunk) {
	console.log('event data ->', chunk);
	data += chunk;
});

// stream end event
rstream.on('end', function() {
	console.log('event end ->', data);
});

// stream error event 
rstream.on('error', function(err) {
	console.log(err.stack);
});

console.log('program end');


